var n=[3,4,15,1,6];
n.sort(function(a,b){
    return a-b;//升序
})
console.log(n);
var by=function(name){
    return function(o,p){
        var a,b;
        if(typeof o==='object' && typeof p==='object' && o && p){
            a=o[name];
            b=p[name];
            if(a===b){
                return 0;
            }
            if(typeof a===typeof b){
                return a<b ? -1 :1;
            }
            return typeof a<typeof b? -1:1;
        }
        else{
            throw{
                name:'error',
                message:'---'+name
            }
        }
    }
}
var s=[
    {first:'Joe'},
    {first:'Moe'},
    {first:'Joe'},
    {first:'Shemp'},
    {first:'Larry'},
    {first:'Curly'}
];
s.sort(by('first'));
console.log(s);
var c='|a|b|c|'.split('|');
console.log(c);
